package cn.itcast.hotel.mq;

import cn.itcast.hotel.constants.Mqconstants;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HotelListener {

    @Autowired
    private IHotelService iHotelService;

    /**
     * 监听酒店（hotel-admin）新增或修改的业务
     * @param id 酒店id
     */
    @RabbitListener(queues = Mqconstants.HOTEL_INSERT_QUEUE)
    public void listenHotelInsertOrUpdate(Long id){
        iHotelService.insertById(id);
    };


    /**
     * 监听酒店（hotel-admin）删除的业务
     * @param id 酒店id
     */
    @RabbitListener(queues = Mqconstants.HOTEL_DELETE_QUEUE)
    public void listenHoteDelete(Long id){
        iHotelService.deleteById(id);
    };


}
